package com.liull.papersystem.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Descriotion:
 * @Author longlong.liu
 * @Version 1.0
 * @Date 2021/10/26 21:16
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    private Integer code;

    private String message;

    private T data;

    // 分页查询的总条数
    private Long count;

    public static Result<Object> success() {
        return success(null, null);
    }

    public static Result<Object> fail(String errorMsg) {
        return new Result<Object>(-1, errorMsg, null, null);
    }

    public static Result<Object> fail() {
        return Result.fail("fail");
    }

    public static <T> Result<T> success(T data, Long count) {
        return new Result<>(0, "success", data, count);
    }

}
